home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / schmdtrp / scheme_d.lha / cmuscheme.elc < prev    next >
Encoding:
Text File  |  1993-07-16  |  12.2 KB  |  224 lines

  1.  
  2. (provide (quote cmuscheme))
  3.  
  4. (require (quote scheme))
  5.  
  6. (require (quote comint))
  7.  
  8. (defvar inferior-scheme-mode-hook nil "\
  9. *Hook for customising inferior-scheme mode.")
  10.  
  11. (defvar inferior-scheme-mode-map nil)
  12.  
  13. (cond ((not inferior-scheme-mode-map) (setq inferior-scheme-mode-map (full-copy-sparse-keymap comint-mode-map)) (define-key inferior-scheme-mode-map "ÿ" (quote scheme-send-definition)) (define-key inferior-scheme-mode-map "" (quote scheme-send-last-sexp)) (define-key inferior-scheme-mode-map " " (quote scheme-load-file)) (define-key inferior-scheme-mode-map " " (quote scheme-compile-file)) (scheme-mode-commands inferior-scheme-mode-map)))
  14.  
  15. (define-key scheme-mode-map "ÿ" (quote scheme-send-definition))
  16.  
  17. (define-key scheme-mode-map "" (quote scheme-send-last-sexp))
  18.  
  19. (define-key scheme-mode-map "" (quote scheme-send-definition))
  20.  
  21. (define-key scheme-mode-map "" (quote scheme-send-region))
  22.  
  23. (define-key scheme-mode-map "" (quote scheme-compile-definition))
  24.  
  25. (define-key scheme-mode-map "" (quote switch-to-scheme))
  26.  
  27. (define-key scheme-mode-map " " (quote scheme-load-file))
  28.  
  29. (define-key scheme-mode-map " " (quote scheme-compile-file))
  30.  
  31. (defun cmuscheme-install-letter-bindings nil "\
  32. This function binds many cmuscheme commands to C-c <letter> bindings,
  33. where they are more accessible. C-c <letter> bindings are reserved for the
  34. user, so these bindings are non-standard. If you want them, you should
  35. have this function called by the cmuscheme-load-hook:
  36.     (setq cmuscheme-load-hook '(cmuscheme-install-letter-bindings))
  37. You can modify this function to install just the bindings you want." (byte-code "┬├─#ê┬┼╞#ê┬╟╚#ê┬╔╩#ê┬╦╠#ê┬═╬#ê┬    ╦╠#ê┬    ═╬#ç" [scheme-mode-map inferior-scheme-mode-map define-key "e" scheme-send-definition-and-go "r" scheme-send-region-and-go "c" scheme-compile-definition-and-go "z" switch-to-scheme "l" scheme-load-file "k" scheme-compile-file] 11))
  38.  
  39. (defun inferior-scheme-mode nil "\
  40. Major mode for interacting with an inferior Scheme process.
  41.  
  42. The following commands are available:
  43. \\{inferior-scheme-mode-map}
  44.  
  45. A Scheme process can be fired up with M-x run-scheme.
  46.  
  47. Customisation: Entry to this mode runs the hooks on comint-mode-hook and
  48. inferior-scheme-mode-hook (in that order).
  49.  
  50. You can send text to the inferior Scheme process from other buffers containing
  51. Scheme source.  
  52.     switch-to-scheme switches the current buffer to the Scheme process buffer.
  53.     scheme-send-definition sends the current definition to the Scheme process.
  54.     scheme-compile-definition compiles the current definition.
  55.     scheme-send-region sends the current region to the Scheme process.
  56.     scheme-compile-region compiles the current region.
  57.  
  58.     Prefixing the scheme-compile/send-definition/region commands with
  59.     a \\[universal-argument] causes a switch to the Scheme process buffer after sending
  60.     the text.
  61.  
  62. For information on running multiple processes in multiple buffers, see
  63. documentation for variable scheme-buffer.
  64.  
  65. Commands:
  66. Return after the end of the process' output sends the text from the 
  67.     end of process to point.
  68. Return before the end of the process' output copies the sexp ending at point
  69.     to the end of the process' output, and sends it.
  70. Delete converts tabs to spaces as it moves back.
  71. Tab indents for Scheme; with argument, shifts rest
  72.     of expression rigidly with the current line.
  73. C-M-q does Tab on each line starting within following expression.
  74. Paragraphs are separated only by blank lines.  Semicolons start comments.
  75. If you accidentally suspend your process, use \\[comint-continue-subjob]
  76. to continue it." (interactive) (byte-code "╚ê╔ ê╩ëê╦ ê╠ëê═ëê╬ëê╧ !ê╨Këê╤Këê╥Këê╙╘!ç" [comint-prompt-regexp major-mode mode-name mode-line-process inferior-scheme-mode-map comint-input-filter comint-input-sentinel comint-get-old-input nil comint-mode "^[^>]*>+ *" scheme-mode-variables inferior-scheme-mode "Inferior Scheme" (": %s") use-local-map scheme-input-filter ignore scheme-get-old-input run-hooks inferior-scheme-mode-hook] 8))
  77.  
  78. (defun scheme-input-filter (str) "\
  79. Don't save anything matching inferior-scheme-filter-regexp" (byte-code "┬    \"?ç" [inferior-scheme-filter-regexp str string-match] 3))
  80.  
  81. (defvar inferior-scheme-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'" "\
  82. *Input matching this regexp are not saved on the history list.
  83. Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters.")
  84.  
  85. (defun scheme-get-old-input nil "\
  86. Snarf the sexp ending at point" (byte-code "è`┴ ê┬`\"))ç" [end backward-sexp buffer-substring] 4))
  87.  
  88. (defun scheme-args-to-list (string) (byte-code "┼╞    \"?â    Cé=╟U?â'    ╟O╚    ╔\\    GO!Bé=┼╩    \" ?â5─é<╚         GO!))ç" [where string t pos nil string-match "[     ]" 0 scheme-args-to-list 1 "[^     ]"] 7))
  89.  
  90. (defvar scheme-program-name "scheme" "\
  91. *Program invoked by the run-scheme command")
  92.  
  93. (fset (quote scheme) (quote run-scheme))
  94.  
  95. (defun run-scheme (&optional cmd) "\
  96. Run an inferior Scheme process, input and output via buffer *scheme*.
  97. If there is a process already running in *scheme*, just switch to that buffer.
  98. With argument, allows you to edit the command line (default is value
  99. of scheme-program-name).  Runs the hooks from inferior-scheme-mode-hook
  100. (after the comint-mode-hook is run).
  101. (Type \\[describe-mode] in the process buffer for a list of commands.)" (interactive (byte-code "à┬├    \"Cç" [current-prefix-arg scheme-program-name read-string "Run Scheme: "] 3)) (byte-code "─ê
  102. å    ╞╟!?à!╚
  103. !╔╩╦ @─ A%qê╠ ))ê╟ëê═╟!ç" [current-prefix-arg scheme-program-name cmd cmdlist nil scheme-buffer comint-check-proc "*scheme*" scheme-args-to-list apply make-comint "scheme" inferior-scheme-mode switch-to-buffer] 8))
  104.  
  105. (defun scheme-send-region (start end &optional and-go) "\
  106. Send the current region to the inferior Scheme process.
  107. Prefix argument means switch-to-scheme afterwards." (interactive "r
  108. P") (byte-code "─ê┼╞     #ê╟╞ ╚\"ê
  109. à╔├!ç" [start end and-go t nil comint-send-region scheme-proc comint-send-string "
  110. " switch-to-scheme] 6))
  111.  
  112. (defun scheme-send-definition (&optional and-go) "\
  113. Send the current definition to the inferior Scheme process.
  114. Prefix argument means switch-to-scheme afterwards." (interactive "P") (byte-code "├êè─ ê`┼ ê╞`\"))ê    à╟┬!ç" [end and-go t nil end-of-defun beginning-of-defun scheme-send-region switch-to-scheme] 5))
  115.  
  116. (defun scheme-send-last-sexp (&optional and-go) "\
  117. Send the previous sexp to the inferior Scheme process.
  118. Prefix argument means switch-to-scheme afterwards." (interactive "P") (byte-code "┴ê┬è├ ê`)`#ç" [and-go nil scheme-send-region backward-sexp] 5))
  119.  
  120. (defvar scheme-compile-exp-command "(compile '%s)" "\
  121. *Template for issuing commands to compile arbitrary Scheme expressions.")
  122.  
  123. (defun scheme-compile-region (start end &optional and-go) "\
  124. Compile the current region in the inferior Scheme process
  125. (A BEGIN is wrapped around the region: (BEGIN <region>)).
  126. Prefix argument means switch-to-scheme afterwards." (interactive "r
  127. P") (byte-code "┼ê╞╟ ╚╚╔╩    
  128. \"\"\"\"ê╞╟ ╦\"ê à╠─!ç" [scheme-compile-exp-command start end and-go t nil comint-send-string scheme-proc format "(begin %s)" buffer-substring "
  129. " switch-to-scheme] 10))
  130.  
  131. (defun scheme-compile-definition (&optional and-go) "\
  132. Compile the current definition in the inferior Scheme process.
  133. Prefix argument means switch-to-scheme afterwards." (interactive) (byte-code "├êè─ ê`┼ ê╞`\"))ê    à╟┬!ç" [end and-go t nil end-of-defun beginning-of-defun scheme-compile-region switch-to-scheme] 5))
  134.  
  135. (defun switch-to-scheme (eob-p) "\
  136. Switch to the scheme process buffer.
  137. With argument, positions cursor at end of buffer." (interactive "P") (byte-code "┬ê├!â─!é┼╞!ê    à╟ êdbç" [scheme-buffer eob-p nil get-buffer pop-to-buffer error "No current process buffer. See variable scheme-buffer." push-mark] 5))
  138.  
  139. (defun scheme-send-region-and-go (start end) "\
  140. Send the current region to the inferior Scheme process,
  141. and switch to the process buffer." (interactive "r") (byte-code "├ê─    ┬#ç" [start end t nil scheme-send-region] 4))
  142.  
  143. (defun scheme-send-definition-and-go nil "\
  144. Send the current definition to the inferior Scheme, 
  145. and switch to the process buffer." (interactive) (byte-code "┴ê┬└!ç" [t nil scheme-send-definition] 2))
  146.  
  147. (defun scheme-compile-definition-and-go nil "\
  148. Compile the current definition in the inferior Scheme, 
  149. and switch to the process buffer." (interactive) (byte-code "┴ê┬└!ç" [t nil scheme-compile-definition] 2))
  150.  
  151. (defun scheme-compile-region-and-go (start end) "\
  152. Compile the current region in the inferior Scheme, 
  153. and switch to the process buffer." (interactive "r") (byte-code "├ê─    ┬#ç" [start end t nil scheme-compile-region] 4))
  154.  
  155. (defvar scheme-source-modes (quote (scheme-mode)) "\
  156. *Used to determine if a buffer contains Scheme source code.
  157. If it's loaded into a buffer that is in one of these major modes, it's
  158. considered a scheme source file by scheme-load-file and scheme-compile-file.
  159. Used by these commands to determine defaults.")
  160.  
  161. (defvar scheme-prev-l/c-dir/file nil "\
  162. Caches the (directory . file) pair used in the last scheme-load-file or
  163. scheme-compile-file command. Used for determining the default in the 
  164. next one.")
  165.  
  166. (defun scheme-load-file (file-name) "\
  167. Load a Scheme file into the inferior Scheme process." (interactive (byte-code "├─    ┬$ç" [scheme-prev-l/c-dir/file scheme-source-modes t comint-get-source "Load Scheme file: "] 5)) (byte-code "─ê┼ !ê╞ !╟ !Bëê╚╔ ╩ ╦Q\"ê╠┬!ç" [scheme-prev-l/c-dir/file scheme-source-modes t file-name nil comint-check-source file-name-directory file-name-nondirectory comint-send-string scheme-proc "(load \"" "\")
  168. " switch-to-scheme] 9))
  169.  
  170. (defun scheme-compile-file (file-name) "\
  171. Compile a Scheme file in the inferior Scheme process." (interactive (byte-code "├─    ┬$ç" [scheme-prev-l/c-dir/file scheme-source-modes nil comint-get-source "Compile Scheme file: "] 5)) (byte-code "┬ê┼ !ê╞ !╟ !Bëê╚╔ ╩ ╦Q\"ê╠─!ç" [scheme-prev-l/c-dir/file scheme-source-modes nil file-name t comint-check-source file-name-directory file-name-nondirectory comint-send-string scheme-proc "(compile-file \"" "\")
  172. " switch-to-scheme] 9))
  173.  
  174. (defvar scheme-buffer nil "\
  175. *The current scheme process buffer.
  176.  
  177. MULTIPLE PROCESS SUPPORT
  178. ===========================================================================
  179. Cmuscheme.el supports, in a fairly simple fashion, running multiple Scheme
  180. processes. To run multiple Scheme processes, you start the first up with
  181. \\[run-scheme]. It will be in a buffer named *scheme*. Rename this buffer
  182. with \\[rename-buffer]. You may now start up a new process with another
  183. \\[run-scheme]. It will be in a new buffer, named *scheme*. You can
  184. switch between the different process buffers with \\[switch-to-buffer].
  185.  
  186. Commands that send text from source buffers to Scheme processes --
  187. like scheme-send-definition or scheme-compile-region -- have to choose a
  188. process to send to, when you have more than one Scheme process around. This
  189. is determined by the global variable scheme-buffer. Suppose you
  190. have three inferior Schemes running:
  191.     Buffer    Process
  192.     foo        scheme
  193.     bar        scheme<2>
  194.     *scheme*    scheme<3>
  195. If you do a \\[scheme-send-definition] command on some Scheme source
  196. code, what process do you send it to?
  197.  
  198. - If you're in a process buffer (foo, bar, or *scheme*), 
  199.   you send it to that process.
  200. - If you're in some other buffer (e.g., a source file), you
  201.   send it to the process attached to buffer scheme-buffer.
  202. This process selection is performed by function scheme-proc.
  203.  
  204. Whenever \\[run-scheme] fires up a new process, it resets scheme-buffer
  205. to be the new process's buffer. If you only run one process, this will
  206. do the right thing. If you run multiple processes, you can change
  207. scheme-buffer to another process buffer with \\[set-variable].
  208.  
  209. More sophisticated approaches are, of course, possible. If you find youself
  210. needing to switch back and forth between multiple processes frequently,
  211. you may wish to consider ilisp.el, a larger, more sophisticated package
  212. for running inferior Lisp and Scheme processes. The approach taken here is
  213. for a minimal, simple implementation. Feel free to extend it.")
  214.  
  215. (defun scheme-proc nil "\
  216. Returns the current scheme process. See variable scheme-buffer." (byte-code "├    ─=â pé
  217. !å┼╞!)ç" [proc major-mode scheme-buffer get-buffer-process inferior-scheme-mode error "No current process. See variable scheme-buffer"] 3))
  218.  
  219. (defvar cmuscheme-load-hook nil "\
  220. This hook is run when cmuscheme is loaded in.
  221. This is a good place to put keybindings.")
  222.  
  223. (run-hooks (quote cmuscheme-load-hook))
  224.